FROM maven:3-eclipse-temurin-17-alpine as builder
WORKDIR application
COPY . .
RUN mvn clean package
ARG JAR_FILE=target/*.jar
RUN ls -la target  # 打印 target 目录下的文件列表
RUN mv ${JAR_FILE} /application/application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre-alpine
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
EXPOSE 7000
ENTRYPOINT ["java", "-Dserver.port=7000", "org.springframework.boot.loader.JarLauncher"]